<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>
<template id="root">
    <div>
      <button @click="showLoginWindow = !showLoginWindow" class="btn btn-success mt-3">登录窗口</button>
  
      <transition name="fade">
        <div v-if="showLoginWindow" class="login-overlay">
          <div class="login-window">
            <h2>用户登录</h2>
            <form @submit.prevent="login">
              <div class="form-group">
                <label for="username">用户名</label>
                <input type="text" id="username" v-model="username" />
              </div>
              <div class="form-group">
                <label for="password">密码</label>
                <input type="password" id="password" v-model="password" />
              </div>
              <button type="submit">登录</button>
            </form>
          </div>
        </div>
      </transition>
    </div>
  </template>
  
  <script>
  const app=Vue.createApp( {
    template:'#root',
    data() {
      return {
        showLoginWindow: false,
        username: '',
        password: ''
      };
    },
    methods: {
      login() {
        // 处理登录逻辑
      }
    }
  });
  const root=  app.mount("#app")
  </script>
  
  <style>
  .fade-enter-active,
  .fade-leave-active {
    transition: opacity 2.5s;
  }
  
  .fade-enter,
  .fade-leave-to {
    opacity: 0;
  }
  
  .login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .login-window {
    background-color: #fff;
    padding: 20px;
    border-radius: 5px;
    max-width: 400px;
    text-align: center;
  }
  
  .login-window h2 {
    margin-bottom: 20px;
  }
  
  .login-window .form-group {
    margin-bottom: 10px;
  }
  
  .login-window label {
    display: block;
    margin-bottom: 5px;
  }
  
  .login-window input[type="text"],
  .login-window input[type="password"] {
    width: 100%;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 3px;
  }
  
  .login-window button {
    padding: 8px 16px;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
  }
  </style>
  </body>
  </html>
  